package com.gzx.plugin.tjzy.modular.word.mediation.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.tjzy.modular.word.mediation.bo.GzxWordMediationAddBo;
import com.gzx.plugin.tjzy.modular.word.mediation.bo.GzxWordMediationQueryBo;
import com.gzx.plugin.tjzy.modular.word.mediation.service.GzxWordMediationService;
import com.gzx.plugin.tjzy.modular.word.mediation.vo.GzxWordMediationVo;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

import java.io.IOException;

/**
 * @author zjt
 * @description
 * @date 2025/3/4 18:21
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/tjzy/word/mediation")
public class GzxWordMediationController {

    private final GzxWordMediationService mediationWordService;

    @PostMapping("/pageList")
    public CommonResult<Page<GzxWordMediationVo>> pageList(@RequestBody GzxWordMediationQueryBo mediationWordQueryBo) {
        return CommonResult.data(mediationWordService.pageList(mediationWordQueryBo));
    }

    @CommonLog("新增调解协议数据")
    @PostMapping("/addOrEdit")
    public CommonResult<String> addOrEdit(@RequestBody GzxWordMediationAddBo mediationWordAddBo) {
        return CommonResult.data(mediationWordService.addOrEdit(mediationWordAddBo));
    }

    @CommonLog("调解协议补全身份证号")
    @GetMapping("/saveDebtorCard/{id}")
    public CommonResult<Void> saveDebtorCard(@PathVariable("id") Long id, @RequestParam("debtorCardId") String debtorCardId) {
        mediationWordService.saveDebtorCard(id, debtorCardId);
        return CommonResult.ok();
    }

    @CommonLog("生成调解协议")
    @GetMapping("/generateMediationWord/{id}")
    public void generateMediationWord(@PathVariable("id") Long id, HttpServletResponse response) throws IOException {
        mediationWordService.generateMediationWord(id, response);
    }

}
